const File = Java.type("java.io.File");  //旧配置文件夹改名
if(FileLib.isDirectory("./config/ChatTriggers/modules/BabyzombieAddons/data")) 
    new File("./config/ChatTriggers/modules/BabyzombieAddons/data").renameTo(new File("./config/ChatTriggers/modules/BabyzombieAddons/config"));

let FirstLoad = false;
if(!FileLib.isDirectory("./config/ChatTriggers/modules/BabyzombieAddons/config")) {
    FileLib.write("./config/ChatTriggers/modules/BabyzombieAddons/config/directory",'',true);
    FileLib.delete("./config/ChatTriggers/modules/BabyzombieAddons/config/directory");
    FirstLoad = true;
}   //自动创建config文件夹

import settings from "./utils/settings";
import {  CheckVersion, getEntities, getPlayerStatus, Auctions, VersionLogs, waypoints, clearTabCompletionMessage, ping, updateModules, getPlayerPos, rayTrace, Vec3iToVec3, openFolder, openBrowse, saveSBProfile, copyEntityNBT, MessageID, ScoreboardLine, FakeBan, isModLoaded, Angle, getTileEntity } from "./utils/utils";
import { location } from "./utils/getLocation";
import { dailycheck } from "./features/dungeon";
import { loadfeatures } from "./features/loadfeatures";
import { note } from "./features/note";
import { SetAttName, misc, sendcoords, serverFinder, showPacket, updateNEUREPO } from "./features/misc";
import { guiMover } from "./utils/gui";
import { GetAndShowKuudraFollowerHelmetPrice, GetAttributesPriceAndItem, GetAttributesPriceFromHeldItem } from "./features/kuudra";
import AttributeHighlightSettings from "./utils/AttributeHighlightSettings";
import { RareDrop } from "./features/raredrop";
import { Vec3 } from "./utils/vec3";
import { SavedData } from "./utils/data";
import { AutoAcceptParty } from "./features/partycommand";
import playCMD from "./features/playCMD";
import petmanager from "./utils/petmanager";


try {
    loadfeatures();
} catch (error) {
    console.error(JSON.stringify(error,undefined,true));
}


const CMDNAME = "babyzombieaddons";
const CMDALIASES = (settings.modulecmd ? settings.modulecmd : "bza");

const helpmessage = new Message(
    new TextComponent(`             §6§lBabyzombieAddons §b§l${JSON.parse(FileLib.read("BabyzombieAddons", "metadata.json")).version} §7§l- §e§lhelp`)
    .setClick("open_url","https://babyzombie.top:5555").setHover("show_text","§6点击此处打开module网页") , ' \n' , 
    new TextComponent(`§1§m                                                                  `).setHover("show_text","§6这是一条分割线") , ' \n' , 
    new TextComponent(`§e/${CMDALIASES} help          §7- §a再次显示此消息`).setClick("run_command",'/' + CMDALIASES + " help")
    .setHover("show_text","§a点击打开此module的帮助页面\n§a其实就是现在这个啦~") , ' \n' ,
    new TextComponent(`§e/${CMDALIASES} settings      §7- §a打开设置页面`).setClick("run_command",'/' + CMDALIASES + " settings")
    .setHover("show_text","§a点击打开此module的设置页面\n§a也可以直接用 /" + CMDALIASES + " s") , ' \n' ,
    new TextComponent(`§e/${CMDALIASES} aa <player>   §7- §a自动接受下一个组队邀请`).setClick("run_command",'/' + CMDALIASES + " aa")
    .setHover("show_text","§a自动接受下一个组队邀请\n§a在指令后面填玩家名可\n§a只接受指定玩家的组队邀请") , ' \n' ,
    new TextComponent(`§e/${CMDALIASES} ap            §7- §a查询各种词条价格`).setClick("run_command",'/' + CMDALIASES + " ap")
    .setHover("show_text",`§e/${CMDALIASES} ap update          §7- §a重新获取auctions数据\n§e/${CMDALIASES} ap hand            §7- §a查询手中物品\n§e/${CMDALIASES} ap <词条> <等级>   §7- §a查询指定词条和等级的价格\n§e/${CMDALIASES} ap <词条> <词条>   §7- §a查询带有指定两种词条的物品`) , ' \n' ,
    new TextComponent(`§e/${CMDALIASES} autois        §7- §a自动返回个人岛屿或花园`).setClick("run_command",'/' + CMDALIASES + " autois")
    .setHover("show_text","§a在世界加载后看看\n§a如果不在skyblock就执行 /play skyblock\n§a如果在skyblock但是不在指定岛屿\n§a就执行/is 或 /warp garden") , ' \n' ,
    new TextComponent(`§e/${CMDALIASES} raredrop      §7- §a稀有掉落屏蔽和自动分享`).setClick("run_command",'/' + CMDALIASES + " raredrop")
    .setHover("show_text","§a点击查看更多帮助") , ' \n' ,
    new TextComponent(`§e/${CMDALIASES} lobbycheck    §7- §a开启房间号检测,看看是否来过`).setClick("run_command",'/' + CMDALIASES + " lobbycheck")
    .setHover("show_text","§a打开以后开始记录\n§a如果过会你又回到这个房间了\n§a就用Title提醒你一下\n§2也可以用 /" + CMDALIASES + " lc") , ' \n' ,
    new TextComponent(`§e/${CMDALIASES} serverfinder  §7- §a自动刷房寻找水晶矿洞房间或地狱或末地`).setClick("suggest_command",'/' + CMDALIASES + " serverfinder ch 13")
    .setHover("show_text",`§a用法: /${CMDALIASES} serverfinder (要找的房间) <房间最低Day>\n§bch (水晶矿洞)  cata (灾难火山的地狱)  drag (正在打龙的末地)`) , ' \n' ,
    new TextComponent(`§e/${CMDALIASES} note          §7- §a记事本功能,可以在开游戏时提示`).setClick("run_command",'/' + CMDALIASES + " note help")
    .setHover("show_text","§a记事本功能\n§a可以在每次开游戏和/ct reload的时候\n§a显示一次记事本内的信息\n§a详见 /" + CMDALIASES + " note help") , ' \n' ,
    new TextComponent(`§e/${CMDALIASES} logs          §7- §a查看历史版本更新日志`).setClick("run_command",'/' + CMDALIASES + " logs")
    .setHover("show_text","§a查询并列出历史版本的更新日志") , ' \n' ,
    new TextComponent(`§1§m                                                                  `).setHover("show_text","§6这是一条分割线")
).setChatLineId(MessageID.Help);

const aphelpmessage = new Message(
    new TextComponent(`§1§m                                                                  `).setHover("show_text","§6这是一条分割线"),'\n',
    new TextComponent(`§e/${CMDALIASES} ap update          §7- §a重新获取auctions数据`).setClick(`run_command`,`/${CMDALIASES} ap update`),'\n',
    new TextComponent(`§e/${CMDALIASES} ap save            §7- §a将获取到的数据保存到本地文件`).setClick(`run_command`,`/${CMDALIASES} ap save`),'\n',
    new TextComponent(`§e/${CMDALIASES} ap hand            §7- §a查询手中物品`).setClick(`run_command`,`/${CMDALIASES} ap hand`),'\n',
    new TextComponent(`§e/${CMDALIASES} ap (词条) (等级)   §7- §a查询指定词条和等级的价格`),'\n',
    new TextComponent(`§e/${CMDALIASES} ap (词条) (词条)   §7- §a查询带有指定两种词条的物品`),'\n',
    new TextComponent(`§a词条可以使用两个字母的缩写,如: br do mp mr mf vi ve sp ll`),'\n',
    new TextComponent(`§1§m                                                                  `).setHover("show_text","§6这是一条分割线")
).setChatLineId(MessageID.Help);


const defaultCommand = ["help","settings","getscoreboard","aa","lobbycheck","lookingat","sendcoords","checkupdate","versionlogs"];

register("command", (...args) => {
    
    if (args[0] == undefined) args[0] = defaultCommand[settings.defaultcommand];

    switch (args[0].toLowerCase()) {
        case "s":  //设置页面
        case "setting":
        case "settings":
            settings.openGUI();
            break;
        case "ping":  //Ping
            ping();
            break;
        case "play":  //游玩菜单(hypixel)
            playCMD.openGUI();
            break;
        case "gs":  //获取计分板
        case "getscoreboard": //Get Scoreboard
            ChatLib.chat(Scoreboard.getLines().length + " §6§l[§r " +ChatLib.removeFormatting(Scoreboard.getScoreboardTitle().toString()) + " §6§l]§r")
            for (let i = Scoreboard.getLines().length - 1; i >= 0; i--) {
                ChatLib.chat(i + " §6§l[§r " + Scoreboard.getLineByIndex(i).toString() + " §6§l]§r");
            };
            break;
        case "at":  //自动转让队长
        case "autotransfer":
            misc.AutoTransfer = !misc.AutoTransfer;
            ChatLib.chat(misc.AutoTransfer ? "§6§l[BZA] §bAuto Transfer §aON" : "§6§l[BZA] §bAuto Transfer §cOFF");
            break;
        case "aa": //自动接受下一个队伍邀请
        case "autoaccpetpartyinvite":
            if (args[1]) {
                AutoAcceptParty.add(args[1],(args[2] ? args[2] : 0));
                ChatLib.chat("§6§l[BZA] §b下一个来自 §6§l" + args[1] + " §b的组队邀请将被自动接受.")
            } else if (AutoAcceptParty.all){
                AutoAcceptParty.all = false;
                ChatLib.chat("§6§l[BZA] §6下一个组队邀请将 §4§l不会 §r§6自动接受.")
            } else {
                AutoAcceptParty.all = true;
                ChatLib.chat("§6§l[BZA] §b下一个组队邀请将会被自动接受.")
            }
            break;
        case "gc":  //聊天栏复读机
        case "getchat":
            misc.getChat = !misc.getChat;
            ChatLib.chat(misc.getChat ? "§6§l[BZA] §b§lget chat §a§lON" : "§6§l[BZA] §b§lget chat §4§lOFF");
            break;
        case "ga":  //actionBar 复读机
        case "getactionbar":
            misc.getActionBar = !misc.getActionBar;
            ChatLib.chat(misc.getActionBar ? "§6§l[BZA] §b§lget ActionBar §a§lON" : "§6§l[BZA] §b§lget ActionBar §4§lOFF");
            break;
        case "packets":  //发包显示
        case "packetsend":
            showPacket.togglePacketSent(args[1] ? args[1] : -1);
            break;
        case "packetr":  //收包显示
        case "packetreceived":
            showPacket.togglePacketReceived(args[1] ? args[1] : -1);
            break;
        case "l":  //在lobby前往limbo
            ChatLib.command("limbo");
            break;
        case "lc":  //房间号检测
        case "lobbycheck":
            misc.lobby = [];
            misc.lobbycheck = !misc.lobbycheck;
            ChatLib.chat(misc.lobbycheck ? "§6§l[BZA] §b§llobby check §a§lON" : "§6§l[BZA] §b§llobby check §4§lOFF");
            break;
        case "sf":  //房间寻找
        case "serverfinder":
            serverFinder.serverFinder(args[1],(args[2] ? args[2] : 0));
            break;
        case "autois":  //autois 便捷开关
        case "is":
            settings.autois = !settings.autois;
            ChatLib.chat(settings.autois ? "§6§l[BZA] §bAutoIs §e已启用" : "§6§l[BZA] §bAutoIs §4已关闭");
            break;
        case "say":  //复读
        case "chat":
            ChatLib.chat(args.splice(1).join(' '));
            break;
        case "note":  //记事本功能
            note(args[1],args);
            break;
        case "guimover":  //Hud位置修改
            guiMover.gui.open();
            break;
        case "ps":
        case "playerstatus":
            if(args[1]) {
                getPlayerStatus(args[1]);
            } else {
                ChatLib.chat("§6§l[BZA] §b用法: /" + CMDALIASES + " ps (想查询的玩家名)")
            }
            break;
        case "playsound":  //声音播放测试
            if(args.length != 4) return ChatLib.chat("§c用法: /" + CMDALIASES + " playsound (声音种类) (音量) (音调)");
            World.playSound(args[1],args[2],args[3]);
            break;
        case "showsound":
            misc.showsound = !misc.showsound;
            ChatLib.chat(misc.showsound ? "§6§l[BZA] §b显示声音 §a§lON" : "§6§l[BZA] §b显示声音 §4§lOFF");
            break;
        case "pv":  //通过sky.shiiyu.moe查询玩家存档
        case "shiyu":
        case "shiiyu":
        case "skycrypt":
            openBrowse("https://sky.shiiyu.moe/" + (args[1] ? args[1] : Player.getName()));
            break;
        case "dd":  //测试功能 - 看看最近一次地牢日run数
        case "dungeondaily":
            if(args[1]){
                dailycheck(args[1]);
            }else{
                dailycheck(Player.getName());
            }
            break;
        case "z":  //标点 - 指针方块
        case "la":
        case "lookingat":
            sendcoords("LookingAt",args.splice(1).join(' '));
            break;
        case "sc":  //标点 - 所在方块
        case "sendcoords":
            sendcoords("Self",args.splice(1).join(' '));
            break;
        case "an":  //词条显示名字
        case "attname":
            if(args.length == 3) SetAttName(args[1],args[2]); else SetAttName();
            break;
        case "ap":  //词条价格查询
        case "att":
        case "ah":
        case "price":
        case "kt":
            switch (args.length) {
                case 1:
                    aphelpmessage.chat();
                    break;
                case 2:
                    switch (args[1]) {
                        case "update":
                            Auctions.getAllAuctionsFromHypixelAPI(true);
                            break;
                        case "cancel":
                            Auctions.cancelUpdate();
                            break;
                        case "hand":
                            GetAttributesPriceFromHeldItem();
                            break;
                        case "save":
                            Auctions.save(false);
                            break;
                        case "load":
                            Auctions.load();
                            break;
                        case "get":
                            Auctions.get();
                            break;
                        case "getconfirm":
                            Auctions.getConfirm();
                            break;
                        case "deleteauctionfiles":
                            Auctions.deleteAuctionFiles();
                            break;
                        default:
                            aphelpmessage.chat();
                            break;
                    }
                case 3:
                    if(args[1] == "load") {
                        Auctions.load(args[2]);
                    } else GetAttributesPriceAndItem(args[1],args[2]);
                    break;
                case 4:
                    GetAttributesPriceAndItem(args[1] + '_' + args[2],args[3]);
                    break;
                case 5:
                    GetAttributesPriceAndItem(args[1] + '_' + args[2],args[3] + '_' + args[4]);
                    break;
            }
            break;
        case "kuudrafollowerhelmetprice":  //Kuudra Follower 帽子价格查询
            let name = (args[1] ? args[1] : Player.getName());
            GetAndShowKuudraFollowerHelmetPrice(name);
            break;
        case "aw":  //添加坐标点
        case "addwp":
        case "addwaypoint":
        case "addwaypoints":
            if(args.length < 2) {ChatLib.chat("§6§l[BZA] §c用法: /" + CMDALIASES + " addwaypoint (名字) (x) (y) (z) <持续时间>§r\n§e持续时间单位为秒,若填写0则会在世界加载时清除,若填写-1则只会在重载时清除");return;}
            if(args.length < 5 || (isNaN(Number(args[args.length - 4])) && isNaN(Number(args[args.length - 1]))) || isNaN(Number(args[args.length - 3])) || isNaN(Number(args[args.length - 2]))) {
                const playerPos = getPlayerPos().toVec3i();
                const blockPos = rayTrace((Client.settings.video.getRenderDistance()*16)^2);
                const waypointCMD = ((args.length == 2 || isNaN(Number(args[args.length-1]))) ? args.join(" ") : args.slice(0,args.length-2).join(" "));
                let waypointHelpMessage = new Message(
                    ("§6§l[BZA] §c用法: /" + CMDALIASES + " addwaypoint (名字) (x) (y) (z) <持续时间>§r\n§e持续时间单位为秒,若填写0则会在世界加载时清除,若填写-1则只会在重载时清除\n§b您是否想要标记   ")
                    );
                waypointHelpMessage.addTextComponent(new TextComponent("§a当前位置").setHoverValue("§a点击在你所在位置添加一个坐标点,坐标是: " + Vec3iToVec3(playerPos).toString())
                    .setClick("run_command","/" + CMDALIASES + " " + waypointCMD + " " + playerPos.x + " " + playerPos.y + " " + playerPos.z + ((args.length == 2 || isNaN(Number(args[args.length-1]))) ? " 0" : " " + args[args.length-1])));
                if(blockPos) {
                    waypointHelpMessage.addTextComponent("   ");
                    waypointHelpMessage.addTextComponent(new TextComponent("§a指针位置").setHoverValue("§a点击在你指针所指方块位置添加一个坐标点,坐标是: " + Vec3iToVec3(blockPos).toString())
                    .setClick("run_command","/" + CMDALIASES + " " + waypointCMD + " " + blockPos.x + " " + blockPos.y + " " + blockPos.z + ((args.length == 2 || isNaN(Number(args[args.length-1]))) ? " 0" : " " + args[args.length-1])));
                }
                waypointHelpMessage.chat();
                return;
            }
            if(isNaN(Number(args[args.length - 4]))) waypoints.addWaypoint(args.splice(1,args.length - 4).join(' '),args[1],args[2],args[3],-1,true);
            else waypoints.addWaypoint(args.splice(1,args.length - 5).join(' '),args[1],args[2],args[3],parseInt(args[4]),true);
            break;
        case "dw":  //删除坐标点
        case "delwp":
        case "delwaypoint":
        case "delwaypoints":
            waypoints.deleteWaypoint(args.splice(1).join(' '));
            break;
        case "mf":  //稀有掉落 屏蔽/自动狗叫
        case "rd":
        case "magicfind":
        case "raredrop":
            RareDrop((args.length == 1 ? ["help"] : args.slice(1)));
            break;
        case "neurepo":    //下载和更新neu repo
        case "updateneurepo": //需要有装neu mod
            updateNEUREPO();
            break;
        case "yaw":  //转视角
        case "pitch":
        case "angle":
        case "rotation":
            Angle.setAngle(args[1],args[2]);
            ChatLib.chat("§6§l[BZA] §a已将您的视角转到§7: §b" + Player.getYaw() + " §7/§b " + Player.getPitch());
            break;
        case "see":
            Angle.lookAt(args[1],args[2],args[3]);
            break;
        case "apikey":
            SavedData.apikey = args[1];
            ChatLib.chat("§6§l[BZA-test] §bapikey已设为: §5" + SavedData.apikey);
            break;
        case "sbapi":  //使用api key获取指定玩家的skyblock当前存档并保存
        case "sbpf":
        case "sbprofile":
        case "sbprofiles":
            saveSBProfile((args[1] ? args[1] : Player.getName()));
            break;
        case "location":  //看看当前位置
            ChatLib.chat(JSON.stringify(location,null,4));
            break;
        case "ge":  //获取附近的实体
        case "getallentities":
            getEntities(args[1]);
            break;
        case "gte":  //获取附近的方块实体
        case "getalltileentities":
            getTileEntity(args[1]);
            break;
        case "copyentity":  //获取指定实体的NBTTAG
            copyEntityNBT(args[1]);
            break;
        case "pet":  //获取当前所使用的宠物
        case "pets":
        case "showpet":
            ChatLib.chat(JSON.stringify(petmanager.getPet()));
            break;
        case "testnum":  //测试数字
            if(args[1]){
                misc.testnum = args[1];
                ChatLib.chat("§6§l[BZA-test] §bsmisc.testnum已设为: §5" + misc.testnum);
            };
            break;
        case "test":
            break;
        case "json":
            FileLib.write(`./config/ChatTriggers/modules/BabyzombieAddons/${args[1]}.json`,JSON.stringify(JSON.parse(FileLib.read(`./config/ChatTriggers/modules/BabyzombieAddons/${args[1]}.json`)),null,4));
            ChatLib.chat("§6§l[BZA] §a文件转好了~");
            break;
        case "chattest":  //send Simulate Chat
            ChatLib.simulateChat(args.splice(1).join(' '));
            break;
        case "mod":
        case "modloaded":
        case "ismodloaded":
            ChatLib.chat("§6§l[BZA-test] §eModLoader§7: " + (isModLoaded(args[1]) ? "§a" + args[1] + " 已加载" : "§e未找到 " + args[1]));
            break;
        case "file":  //打开此module的文件夹
        case "files":
            openFolder('./config/ChatTriggers/modules/BabyzombieAddons');
            break;
        case "cheat":  //虚假禁令
        case "fakeban":
        case "gb":
        case "ghostblock":
            FakeBan((args[1] ? args[1] : "5"));
            break;
        case "nametag":
            if(args[1] == "toggle") {
                misc.NameTag = !misc.NameTag;
                ChatLib.chat("§6§l[BZA] §eNameTag§7: " + (misc.NameTag ? "§a已启用" : "§c已禁用"));
            } else helpmessage.chat();
            break;
        case "jasper":
        case "jasperfinder":
            misc.jasperFinder = !misc.jasperFinder;
            ChatLib.chat("§6§l[BZA] §eJasper Finder§7: " + (misc.jasperFinder ? "§a已启用§7,§e已加载区块的信息不会立刻获取" : "§c已禁用"));
            break;
        case "unload":
            ChatTriggers.unloadCT(true);
            break;
        case "load":
        case "reload":
            ChatTriggers.reloadCT();
            break;
        case "resethudlocation":
            guiMover.reset();
            break;
        case "update":  //更新module
            if(args[1]) {
                updateModules(args[1]);
                break;
            };
        case "checkupdate":  //检测更新
            CheckVersion(true);
            break;
        case "log":  //历史更新日志
        case "logs":
        case "versionlogs":
        case "changelogs":
            VersionLogs();
            break;
        case "ignoreupdateversion":
            if(!args[1]) return;
            SavedData.IgnoreVersion = args[1];
            ChatLib.chat("§6§l[BZA] §c" + args[1] + "版本的更新提示将不会再次显示");
        case "atth":
        case "ahighlight":
            if (args.length === 1) {
                ChatLib.chat("§6§l[BZA] §b属性高亮指令帮助:");
                ChatLib.chat("§e/" + CMDALIASES + " ahighlight toggle §7- §a开关高亮功能");
                ChatLib.chat("§e/" + CMDALIASES + " ahighlight att1 <词条> §7- §a设置第一个词条");
                ChatLib.chat("§e/" + CMDALIASES + " ahighlight att2 <词条> §7- §a设置第二个词条");
                ChatLib.chat("§e/" + CMDALIASES + " ahighlight color <R> <G> <B> [A] §7- §a设置颜色 (0-255)");
                ChatLib.chat("§e/" + CMDALIASES + " ahighlight mode <any|both> §7- §a设置匹配模式");
                return;
            }
            switch (args[1].toLowerCase()) {
                case "toggle":
                    AttributeHighlightSettings.AttributeHighlight = !AttributeHighlightSettings.AttributeHighlight;
                    ChatLib.chat(`§6§l[BZA] §b属性高亮已 ${AttributeHighlightSettings.AttributeHighlight ? "§a启用" : "§c禁用"}`);
                    break;
                case "att1":
                    if (args.length < 3) {
                        ChatLib.chat("§c用法: /" + CMDALIASES + " ahighlight att1 <词条>");
                        return;
                    }
                    AttributeHighlightSettings.AttributeHighlightAtt1 = args[2];
                    ChatLib.chat(`§6§l[BZA] §b第一个词条已设置为: §a${args[2]}`);
                    break;
                case "att2":
                    if (args.length < 3) {
                        ChatLib.chat("§c用法: /" + CMDALIASES + " ahighlight att2 <词条>");
                        return;
                    }
                    AttributeHighlightSettings.AttributeHighlightAtt2 = args[2];
                    ChatLib.chat(`§6§l[BZA] §b第二个词条已设置为: §a${args[2]}`);
                    break;
                case "color":
                    if (args.length < 5) {
                        ChatLib.chat("§c用法: /" + CMDALIASES + " ahighlight color <R> <G> <B> [A]");
                        return;
                    }
                    const r = parseInt(args[2]) / 255;
                    const g = parseInt(args[3]) / 255;
                    const b = parseInt(args[4]) / 255;
                    const a = args.length > 5 ? parseInt(args[5]) / 255 : 0.5;
                    AttributeHighlightSettings.AttributeHighlightColor = new java.awt.Color(r, g, b, a);
                    ChatLib.chat(`§6§l[BZA] §b高亮颜色已设置为: §cR:${args[2]} §aG:${args[3]} §bB:${args[4]} §7A:${args.length > 5 ? args[5] : 128}`);
                    break;
                case "mode":
                    if (args.length < 3) {
                        ChatLib.chat("§c用法: /" + CMDALIASES + " ahighlight mode <any|both>");
                        return;
                    }
                    if (args[2].toLowerCase() === 'any') {
                        AttributeHighlightSettings.AttributeHighlightMode = 0;
                        ChatLib.chat("§6§l[BZA] §b匹配模式已设置为: §a匹配任意一个");
                    } else if (args[2].toLowerCase() === 'both') {
                        AttributeHighlightSettings.AttributeHighlightMode = 1;
                        ChatLib.chat("§6§l[BZA] §b匹配模式已设置为: §a匹配全部");
                    } else {
                        ChatLib.chat("§c无效的模式. 请使用 'any' 或 'both'.");
                    }
                    break;
                default:
                    ChatLib.chat("§c无效的属性高亮子命令. 使用 /" + CMDALIASES + " ahighlight 查看帮助.");
                    break;
            }
            break;
        default:  //如果不是上面那些就显示帮助文本
            helpmessage.chat();
            break;
    }
}).setName(CMDNAME).setAliases(CMDALIASES);


//指令提示与补全
const tabCompletions = {
    "autoaccpetpartyinvite" : "自动接受下一个发来的队伍邀请\n§7可以在后面跟玩家名,将会只自动接受指定玩家的队伍邀请",
    "autotransfer" : "自动转队长,有人把队长转给你后自动转回去",
    "ap" : `§7词条价格查询 (市场最低价并不一定代表这个东西真的值这个价)\n§7/${CMDALIASES} ap update          §7- §7重新获取auctions数\n§7/${CMDALIASES} ap hand            §7- §7查询手中物品\n§7/${CMDALIASES} ap (词条) (等级)   §7- §7查询指定词条和等级的价\n§7/${CMDALIASES} ap (词条) (词条)   §7- §7查询带有指定两种词条的物品\n§7词条可以使用两个字母的缩写,如: br do mp mr mf vi ve sp ll`,
    "settings" : "module的设置页面",
    "pv" : "在SkyCrypt中查询自己或别人的Skyblock存档,会直接打开浏览器",
    "lobbycheck" : "开启和关闭房间检测,在你进入重复的房间时会在右下角弹提示",
    "serverfinder" : `自动刷房寻找水晶矿洞房间或地狱或末地\n§7用法: /${CMDALIASES} serverfinder (要找的房间) <房间最低Day>\n§7ch (水晶矿洞)  cata (灾难火山的地狱)  drag (正在打龙的末地)`,
    "addwaypoint" : `在屏幕上添加一个坐标点\n§7用法 : /${CMDALIASES} addwaypoint (名字) (x) (y) (z) <时间>\n§7持续时间单位为秒,若填写0则会在世界加载时清除,若填写-1则只会在重载时清除`,
    "delwaypoint" : `删除一个已经添加的坐标点\n§7用法 : /${CMDALIASES} delwaypoint (坐标点名字)`,
    "raredrop" : `稀有掉落信息屏蔽和自动发送,输入以下指令获取更多帮助信息\n§7/${CMDALIASES} raredrop ignore - 屏蔽稀有掉落提示\n§7/${CMDALIASES} raredrop share  - 稀有掉落复制和自动发送`,
    "attname" : `修改在物品上面显示词条的显示文本和颜色`,
    "kuudrafollowerhelmetprice" : `查询自己或其他人今天的 Kuudra Follower 帽子的价格\n§7/${CMDALIASES} kuudrafollowerhelmetprice <玩家名>     玩家名不填就是查自己的`,
    "autois" : "开关autoIS,开启后会自动返回个人岛屿或花园",
    "note" : "一个小的记事功能,会在每次游戏启动后第一次进入世界时显示里面的内容",
    "sendcoords" : "发送当前坐标, 后面跟 pc cc ac gc 可以指定发送的频道",
    "lookingat" : "发送指针指向的方块的坐标, 后面跟 pc cc ac gc 可以指定发送的频道",
    "ping" : "随便发点什么指令看看服务器多久后回复就知道多少延迟了",
    "help" : "显示此module的老帮助信息 (你现在看到的就是新的)",
    "checkupdate" : "检测更新,看看是否有更新版本的此module",
    "logs" : "查看此module历史版本的更新日志"
}
if(FileLib.exists("./config/notenoughupdates")) tabCompletions["neurepo"] = "从github下载个neu的repo并替换掉现有的,下载的时候可能会未响应一会";


let tabCounter = 0;
let tabCompletion = [];
register("guiKey", (char,key,gui,event) => {
    if(!Client.isInChat()) return;
    if(key != Keyboard.KEY_TAB) {tabCounter = 0;tabCompletion = [];return;}
    let cmd = Client.getCurrentChatMessage();
    if(!(cmd.startsWith("/" + CMDNAME + " ") || cmd.startsWith("/" + CMDALIASES + " "))) return;
    let cmdArray = cmd.split(' ');
    if(cmdArray.length > 2) {
        if(tabCompletions[cmdArray[1]]) {
            new Message("§7" + cmdArray[1] + " : " + tabCompletions[cmdArray[1]]).setChatLineId(MessageID.TabCompletion).chat();
            clearTabCompletionMessage.clearNext();
        }
        return;
    }
    if(tabCompletion.length == 0) {
        for (let key in tabCompletions) { if(key.toLowerCase().startsWith(cmdArray[1].toLowerCase())) tabCompletion.push(key); }
    }
    if(tabCompletion.length == 0) return;
    Client.setCurrentChatMessage(cmdArray[0] + " " + tabCompletion[tabCounter]);
    let tabMessage = tabCompletion.slice();
    tabMessage[tabCounter] = "§f" + tabMessage[tabCounter] + "§7";
    new Message("§7" + tabMessage.join(', ') + (tabCompletions[tabCompletion[tabCounter]] ? ("\n§f" + tabCompletion[tabCounter] + " §7: " + tabCompletions[tabCompletion[tabCounter]]) : '')).setChatLineId(MessageID.TabCompletion).chat();
    clearTabCompletionMessage.clearNext();
    if(++tabCounter >= tabCompletion.length) tabCounter = 0;
});


//首次加载提示
if(FirstLoad) {
    const FirstLoadThing = register("worldLoad", () => {
        setTimeout(() => {
            new Message(
                new TextComponent(`§1§m                                                                  \n`).setHover("show_text","§6这是一条分割线§r"),
                "§b感谢您使用 ",new TextComponent("§6§lBabyzombieAddons").setClick("open_url","https://babyzombie.top:5555").setHover("show_text","§6点击此处打开module网页")," §7(§eChatTriggers Module§7)\n",
                "§a当前Module版本§7:§a ", new TextComponent(JSON.parse(FileLib.read("BabyzombieAddons", "metadata.json")).version).setClick("run_command","/babyzombieaddons versionlogs").setHover("show_text","§b点击查看其他版本的更新日志"),"\n",
                "§eModule功能开关可进入 ",new TextComponent("§5§l§n设置").setClick("run_command","/babyzombieaddons settings").setHover("show_text","§b点击进入Module设置,平时可以使用指令打开")," §a查看\n",
                "§e使用 ",new TextComponent("§a§l§n/bza help").setClick("run_command","/babyzombieaddons help").setHover("show_text","§b点击查看指令帮助")," §e可以查看更多Module功能和帮助\n",
                new TextComponent(`§1§m                                                                  `).setHover("show_text","§6这是一条分割线§r")
            ).chat();
        }, 3000);
        FirstLoadThing.unregister();
    })
}